#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"

int main(int argc, char *argv[])
{
  uint maxBytesWrote = 1024*1024 - (512*12+512*128);
  char *buf = malloc(maxBytesWrote);
  uint fd = open(argv[1],O_CREATE|O_RDWR);
  if(fd<=0)
    {
        printf(1,"file open filed:%d\n",fd);
        exit();
    }

    if(write(fd,&buf,512*12)!=512*12)
      {
        printf(1,"Failed to write\n");
        close(fd);
        exit();
      }
  printf(1,"Finished writing 6KB (direct)\n");
    if(write(fd,&buf,512*128)!=512*128)
        {
        printf(1,"Failed to write\n");
        close(fd);
        exit();
        }
  printf(1,"Finished writing 70KB (single indirect)\n");
  if(write(fd,&buf,(maxBytesWrote))!=(maxBytesWrote))
        {
        printf(1,"Failed to write\n");
        close(fd);
        exit();
        }
  printf(1,"Finished writing 1MB\n");
        close(fd); 
  exit();
}
